import request from "@/utils/request";

export enum StationStatus {
  建设中 = 1,
  运营中 = 2,
  暂停运营 = 3,
  已关闭授权 = 8,
}
export enum FeeType {
  平时 = 1,
  谷时 = 2,
  峰时 = 3,
  尖时 = 4,
}
export interface FeeInfo {
  type: FeeType
  /** 单位分钟 小时*60 + 分钟 */
  startTime: number
  /** 单位分钟 小时*60 + 分钟 */
  endTime: number
  electricFee: number
  serviceFee: number
}
export enum StationDevice {
  卫生间 = 1,
  餐饮 = 2,
  休息室 = 3,
  雨棚 = 4,
  有人值守 = 5,
  便利店 = 6,
}
export enum StationParkType {
  免费 = 1,
  限时免费 = 2,
  收费 = 3
}
export enum StationGround {
  地上 = 1,
  地下 = 2,
}
export enum StationInvoice {
  支持 = 1,
  不支持 = 2,
}
export interface Station {
  /** 交流状数量 */
  acNum: number
  nickname:string
  telephone:string
  acChargeNum: number
  acErrorNum: number
  acFreeNumb: number
  acOccupyNum: number
  acOffLineNum: number
  acOtherNum: number
  /** 详细地址 */
  address: string
  /** 省份ID */
  provinceId: string
  /** 城市ID */
  cityId: string
  /** 区县ID */
  areaId: string
  /**  */
  createAccount: string
  /** 创建时间 */
  createTime: number
  /** 直流桩数量 */
  dcNum: number
  dcChargeNum: number
  dcErrorNum: number
  dcFreeNumb: number
  dcOccupyNum: number
  dcOffLineNum: number
  dcOtherNum: number
  /**
   * 设备列表, 逗号分隔
   * @type StationDevice
   */
  deviceList: string
  /**  */
  directCharge: number
  /** 电价 [[700,0.1000,0.5000,1],[900,0.6000,0.8000,3],[1200,0.8000,0.4000,2],[1800,0.6000,0.5000,1],[2300,0.8000,0.5000,2],[2359,0.1200,0.3000,2]] */
  feeInfo: string
  /**  */
  fromType: number
  id: string
  /** 场站图片，逗号分割 */
  imgs: string
  /**  0,  */
  kw: number
  /** 纬度 */
  latitude: number
  /** 经度 */
  longitude: number
  /**  */
  notice: string
  /**  */
  operatorId: string
  /** */
  ownerId: string
  /** 停车说明 */
  parkInfo: string
  /** 停车费用类型 */
  parkType: StationParkType
  /** 评分 */
  score: number
  /**  */
  fee_info: string
  /** 服务时间 */
  serviceTime: string
  /** 场站介绍 */
  stationInfo: string
  /** 场站名称 */
  stationName: string
  /** 状态 */
  status: StationStatus
  /** 设备数量 */
  stubNum: number
  /**  */
  thirdId: string
  /**  */
  updateAccount: string
  /**  */
  updateTime: number
  /** 经销商 ID */
  orgId: number
  /** 经销商名称 */
  orgName: string
  /** 场站类型 */
  ground: StationGround
  /** 是否支持开票 */
  invoice: StationInvoice
  /** 联系方式 */
  managerInfo: string
}
export interface QueryStationListParams extends PaginationParams {
  title?: string
  status?: StationStatus
  orgId?: string
  cityId?: number
  fromType?: number
  ownerType?: number
}
export async function queryStationList(data: QueryStationListParams) {
  return request<Station[]>('/app/manager/station/list', {data})
}

export async function editStation(data: Partial<any>) {
  return request('/app/manager/station/addOrUpdate', {data})
}

export async function getStationInfo(data: {stubGroupId: string}) {
  return request<any>('/app/manager/station/detail', {data})
}

export async function modifyFeeInfo(data: {id: string, feeInfo: string}) {
  return request('/app/manager/station/modifyFeeInfo', {data})
}

export async function queryStationListForSelectOption() {
  return request<{id: string, name: string}[]>('/app/manager/station/dic', {
    data: {},
  })
}

export interface TencentSearchResult {
  status: number
  message: string
  data: {
    title: string
    address: string
    location: {
      lat: number
      lng: number
    }
  }[]
}

export async function searchRegion(data: {title: string, cityId: string}) {
  return request('/app/manager/keyword', {data})
}

export async function geocoder(data: {locX: number, locY: number}) {
  return request('/app/manager/geocoder', {data})
}

export async function getWhiteList(data: any) {
  return request('/app/manager/person/stu/white/list', {data})
}

export async function saveWhiteList(data: any) {
  return request('/app/manager/person/stu/white/addOrUp', {data})
}

export async function queryEquipmentList(params: any) {
  return request<any[]>('/app/manager/equipment/list', {
    data: params,
  })
}
